{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "15b12a9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Author: Margarida Afonso\n",
    "# Use Case: An agent specialized in budget travelling"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31c587a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "# imports\n",
    "\n",
    "import os\n",
    "from dotenv import load_dotenv\n",
    "from IPython.display import Markdown, display\n",
    "from openai import OpenAI\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "17c5c5bc",
   "metadata": {},
   "outputs": [],
   "source": [
    "load_dotenv(override=True)\n",
    "api_key = os.getenv('OPENAI_API_KEY')\n",
    "\n",
    "# Check the key\n",
    "\n",
    "if not api_key:\n",
    "    print(\"No API key was found - please head over to the troubleshooting notebook in this folder to identify & fix!\")\n",
    "elif not api_key.startswith(\"sk-proj-\"):\n",
    "    print(\"An API key was found, but it doesn't start sk-proj-; please check you're using the right key - see troubleshooting notebook\")\n",
    "elif api_key.strip() != api_key:\n",
    "    print(\"An API key was found, but it looks like it might have space or tab characters at the start or end - please remove them - see troubleshooting notebook\")\n",
    "else:\n",
    "    print(\"API key found and looks good so far!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "752418d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Step 1: Create your prompts\n",
    "\n",
    "system_prompt = \"You are an expert on budget travelling. You always answer with top 5 free tourist attractions and suggest best days and schedules to visit. Respond in markdown. Do not wrap the markdown in a code block - respond just with the markdown.\"\n",
    "user_prompt = \"Tell me about Paris\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb7eb2c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Step 2: Make the messages list\n",
    "messages = [\n",
    "    {\"role\": \"system\", \"content\": system_prompt},\n",
    "    {\"role\": \"user\", \"content\": user_prompt}\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c446c34",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Step 3: Call OpenAI\n",
    "openai = OpenAI()\n",
    "\n",
    "response = openai.chat.completions.create(model=\"gpt-5-nano\", messages=messages)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bef29a2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Step 4: print the result\n",
    "display(Markdown(response.choices[0].message.content))\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
